// 获取css属性
function getCss(curEle,attr){  
    var val = null,reg = null;  
    if("getComputedStyle" in window){  
        val = window.getComputedStyle(curEle,null)[attr];  
    } else {   //ie6~8不支持上面属性  
        //不兼容  
        if(attr === "opacity"){  
            val = curEle.currentStyle["filter"];   //'alpha(opacity=12,345)'  
            reg = /^alphaopacity=(\d+(?:\.\d+)?)opacity=(\d+(?:\.\d+)?)$/i;  
            val = reg.test(val)?reg.exec(val)[1]/100:1;  
        } else {  
            val = curEle.currentStyle[attr];  
        }  
    }  
    reg = /^(-?\d+(\.\d)?)(px|pt|em|rem)?$/i;  
    return reg.test(val)?parseFloat(val):val;   
  }

const {clipboard} = require('electron')
//   js获取鼠标选中的文字写入剪切板
function SelectText()
{
      try{
            var selecter=window.getSelection().toString();
            if(selecter!=null&&selecter.trim()!=""){
                clipboard.writeText(selecter)
            }
      }catch(err){
            var selecter=document.selection.createRange();
            var s=selecter.text;
            if(s!=null&&s.trim()!=""){
                console.log(err);
            }
      }
}
//替换文本前与后的空格
String.prototype.trim=function()
{
      return this.replace(/(^\s*)|(\s*$)/g,"");
}

// 读取剪切板中的数据
function openText(){
    return clipboard.readText();
}